﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SoundServant.Controls;

namespace SoundServant
{
    /// <summary>
    /// Interaction logic for AddCD.xaml
    /// </summary>
    public partial class AddCDWindow : SSWindow
    {
        StoredRecording recording;
        Burner max;

        public AddCDWindow(StoredRecording r, Burner m)
        {
            InitializeComponent();

            recording = r;
            max = m;

            RecordingViewHolder.Content = new RecordingReadOnlyControl(recording);

            foreach (StoredDisc disc in recording.Discs)
            {
                DiscChooserControl discChooserControl = new DiscChooserControl(disc);
                DiscsSelectorWrapPanel.Children.Add(discChooserControl);
            }
        }

        private void BurnCDButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (DiscChooserControl discChooserControl in DiscsSelectorWrapPanel.Children)
            {
                if ((bool)discChooserControl.IsChecked)
                {
                    if (discChooserControl.Disc.Error)
                        SSMessageBox.Show("Disc " + discChooserControl.Disc.Number + " cannot be burnt, one or more tracks contains an error", "Error", SSMessageBoxType.Ok);
                    else
                        max.AddCD(new CD(discChooserControl.Disc, ForWho.Text, max));
                }
            }
            this.Close();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ForWho.Focus();
        }


    }
}
